package top.ivansong92.example.leetcode.learning.data.struct.array.extension.queue;

import top.ivansong92.example.leetcode.learning.data.struct.array.extension.NewArrayV2;

import java.util.ArrayList;
import java.util.List;

public class NewArrayQueue<E> implements NewQueue<E> {

    private NewArrayV2<E> array;

    public NewArrayQueue(int capacity) {
        array = new NewArrayV2<>(capacity);
    }

    public NewArrayQueue() {
        this(8);
    }

    @Override
    public void enqueue(E e) {
        array.addLast(e);
    }

    @Override
    public E dequeue() {
        return array.removeFirst();
    }

    @Override
    public E getHeader() {
        return array.getFirst();
    }

    @Override
    public int size() {
        return array.size();
    }

    @Override
    public boolean isEmpty() {
        return array.isEmpty();
    }

    @Override
    public String toString() {
        return "NewArrayQueue:[head,...,trail](" + array + ")";
    }

    public static void main(String[] args) {
        NewQueue<String> queue = new NewArrayQueue<>();
        queue.enqueue("12312");
        queue.enqueue("asdsad");
        List<String> list = new ArrayList<>(Integer.MAX_VALUE);

        System.out.println(queue.getHeader());
        System.out.println(queue.dequeue());
        System.out.println(queue);
    }
}
